<template>
  <div>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="studentData.currentPage"
      :page-sizes="[5, 10, 20]"
      :page-size="5"
      layout="total, sizes, prev, pager, next"
      :total="studentData.totalStudent"
    >
    </el-pagination>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const {
  mapState: stuMapState,
  mapMutations: stuMapMutations,
  mapActions: stuMapActions,
} = createNamespacedHelpers("student");

export default {
  computed: {
    ...stuMapState(["studentData"]),
  },
  data() {
    return {};
  },
  //监听vuex 中的页码 变化并执行 获取学生 刷新数据
  watch: {
    "studentData.currentPage"(newValue) {
      this.getStudent();
    },
    "studentData.pageSize"(newValue) {
      this.getStudent();
    },
  },
  methods: {
    ...stuMapMutations(["toggleCurrentPage", "togglePageSize", "getState"]),
    ...stuMapActions(["getStudent"]),
    handleCurrentChange(val) {
      this.toggleCurrentPage(val);
    },
    handleSizeChange(val) {
      this.togglePageSize(val);
    },
  },
};
</script>

<style>
</style>